import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { join } from "path";
// import styleImport, { VantResolve } from 'vite-plugin-style-import'
import postCssPxToRem from "postcss-pxtorem"
// https://vitejs.dev/config/
// console.log(styleImport)
// 
// function _resolve(dir: string) {
//   return path.resolve(__dirname, dir)
// }
export default defineConfig({
  plugins: [vue()
    // styleImport({
    //   resolves: [VantResolve()]
    // })
  ],
  css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 37.5, // 1rem的大小(设计稿宽度的1/10)
          propList: ['*'], // 需要转换的属性，这里选择全部都进行转换
        })
      ]
    }
  },
    // 配置项目别名
  resolve: {
      alias: {
        '@': join(__dirname, '/src'),
      },
  },
  server:{
    proxy:{
      '/app-dev': {
        target: 'https://m.ximalaya.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/app-dev/, ''),
      },
      '/login': {
        target: 'http://sph-h5-api.atguigu.cn',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/login/, ''),
      }
    }
  }
})
